const reverseWords = function (s: string): string {

    return s.trim().split(/\s+/)
        .join(' ')
};


console.log(reverseWords(" a good   example "));